#ifndef AUDIOSTATUSMONITOR_H
#define AUDIOSTATUSMONITOR_H

#include <QWidget>
#include <QLabel>

#include "svideowidget.h"

namespace Ui {
class audioStatusMonitor;
}

/*
    继承了 QWidget GUI类
    整体功能:
        作为音视频的监视类，用于statusBar里面的GUI相关功能，通过槽函数接受SVideoWidget相关信号。
    具体功能:
        1、进度条、当前进度、总时间
        2、后退、前进、播放/暂停
        3、音量大小、播放方式、播放速率
*/

class audioStatusMonitor : public QWidget
{
    Q_OBJECT

public:
    explicit audioStatusMonitor(SVideoWidget* video, QWidget *parent = nullptr);
    ~audioStatusMonitor() override;

signals:
    void ButtonSoundClicked(int value);

protected:
    bool eventFilter(QObject *watched, QEvent *event) override;

private slots:
    void UpdateUI();
    void UpdateCurrentTime(qint64 currentTime);
    void UpdateButtonSwitch(bool isPlaying);
    void UpdateButtonMod(bool isLoop);
    void UpdateButtonSound(float volume);
    void ClickButtonBackward();
    void ClickButtonForward();
    void ClickButtonPlaySound();
    void ClickButtonPlayRate();
    void PressProgressSlider();
    void ReleaseProgressSlider();

private:
    void Init();
    void InitThumbnailPreviewUi();
    void ConnectAll();

    Ui::audioStatusMonitor *ui;
    SVideoWidget* mVideoWidget {nullptr};
    QLabel* mThumbnailPreview {nullptr};
    QLabel* mThumbnailTimeLabel {nullptr};
    QMediaPlayer* mPreviewPlayer {nullptr};
    QTimer* mPreviewTimer {nullptr};
    bool mProgressSliderPressed {false};
};

#endif // AUDIOSTATUSMONITOR_H
